package com.ntnhu2008.actionbar;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;

public class ActionBarSampleActivity extends Activity {
	/** Called when the activity is first created. */
	ActionBar actionbar;
	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.main);
		actionbar = (ActionBar) findViewById(R.id.acts);
		Action action = new IntentAction(R.drawable.ic_title_share_default, this, createShareIntent());
		actionbar.addAction(action);
		Action action2 = new IntentAction(R.drawable.zoomin, this, null);
		actionbar.addAction(action2);
	}
	public static Intent createIntent(Context context) {
        Intent i = new Intent(context, ActionBarSampleActivity.class);
        i.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
        return i;
    }

    private Intent createShareIntent() {
        final Intent intent = new Intent(Intent.ACTION_SEND);
        intent.setType("text/plain");
        intent.putExtra(Intent.EXTRA_TEXT, "Shared from the ActionBar widget.");
        return Intent.createChooser(intent, "Share");
    }
}